<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Aplayer使用ajax</title>
  <link rel="stylesheet" href="../static/music/APlayer.min.css">
  <script src="../static/music/APlayer.min.js"></script>
</head>
<body>
<!--<div id="aplayer"></div>-->

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>
    var audio = []; // 储存返回来的信息

    $.ajax({
        url: "http://localhost:8080/music/getPlayList",// 请求的url地址
        type: "get",// get或者post
        data: {},//请求的参数
        dataType: "json",//json写了jq会帮我们转换成数组
        success: function(data){//请求成功返回
            const ap = new APlayer({
                container: document.getElementById('aplayer'),
                audio: [{
                    name: data.name,
                    artist: data.artist,
                    url: data.url,
                    cover: data.cover
                }]
            });
        },
        error: function () {//请求失败返回
        }
    })




</script>

</body>
</html>